$(function(){
	showMessage();
});	
//教练加载信息
function showMessage(){
	$.ajax({
		url:"/vi_user_coach/selectByUid",
		type:"post",
		success:function(data){
			// 改变头像图片源
			if (data.headImage == ""||data.headImage==null) {
				//设置默认头像图片
				$("#my-img").attr("src", "/images/滑稽.png");
				}
			else{
			$("#my-img").attr("src", "/images/" + data.headImage);
			}
			if(data.nickName==null ||data.nickName==""){
				data.nickName="未知";
			}
			if(data.cname==null||data.cname==""){
				data.cname="未知"
			}
			if(data.csex==null || data.csex==""){
				data.csex="未知"
			}
			if(data.cage==null || data.cage==""){
				data.cage="未知"
			}
			if(data.time==null ||data.time==""){
				data.time="未知"
			}
			if(data.price==null ||data.price==""){
				data.price="未知"
			}
			if(data.style==null|| data.style==""){
				data.style="未知"
			}
			if(data.publicLevel==0){
				data.publicLevel="所有人可见"
			}
			if(data.publicLevel==1){
				data.publicLevel="仅好友可见";
			}
			if(data.publicLevel==2){
				data.publicLevel="私密(仅自己可见)"
			}
			if(data.authentication==0){
				data.authentication="未认证"
			}
			if(data.authentication==1){
				data.authentication="场馆认证"
			}
			if(data.address==null || data.address==""){
				data.address="未知"
			}
			if(data.content==null ||data.content==""){
				data.content="未知"
			}
			if(data.cintroduction==null ||data.cintroduction==""){
				data.cintroduction="未知"
			}
			// 通过改变 text的value值来显示的信息
			var content ='<div class="layui-form-item" style="font-size: 20px; text-align: center" >基本信息</div>';
			var nickName ='<label class="layui-form-label" ">昵称</label>'
				+'<div class="layui-input-inline">'
			    +'<input type="text" name="nickName"  required lay-verify="required" value="'+data.nickName+'" disabled="disabled" autocomplete="off" class="layui-input">'		
				+'</div>'
			var cname ='<label class="layui-form-label" >真实姓名</label>'
				+'<div class="layui-input-inline">'
			    +' <input type="text" name="cname" value="'+data.cname+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input">'		
				+'</div>';
			var sex='<div class="layui-form-item" >'
				    +'  <label class="layui-form-label">性别</label>'
					+'<div class="layui-input-inline">'
				    +' <input type="text" name="sex" value="'+data.csex+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input">'		
					+'</div></div>'
			var cage='<label class="layui-form-label" >年龄</label><div class="layui-input-inline" >'
			  		+'<input type="text" name="cage" value="'+data.cage+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input"></div>'		 
			var time='<label class="layui-form-label" >上课时间</label>'
				+'<div class="layui-input-inline" >'
				+'<input type="text" name="time" value="'+data.time+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input"></div>';
			  
			var price ='<label class="layui-form-label">课程价格</label>'
				+'<div class="layui-input-inline">'
					+'<input type="text" name="price" value="'+data.price+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input"></div>'
			var style='<label class="layui-form-label">瑜伽流派</label>'
			  	+'<div class="layui-input-inline">'
			  	+'<input type="text" name="style" value="'+data.style+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input"></div> '
			var publicLevel =' <div class="layui-form-item">'
			   +'<label class="layui-form-label">信息级别</label>'
			   +'<div class="layui-input-inline">'
			 	+'<input type="text" name="publicLevel" value="'+data.publicLevel+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input">'
			 	+'</div></div>'		
			var authentication ='<div class="layui-form-item" >'
			   +' <label class="layui-form-label">认证</label>'
			   +'<div class="layui-input-inline">'
				+'<input type="text" name="authentication" value="'+data.authentication+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input">'	
			  +'</div></div> '
			var address='<div class="layui-form-item" >'
			   +' <label class="layui-form-label">地址</label>'
			   +'<div class="layui-input-inline" style="width: 70%;">'
				+'<input type="text" name="authentication" value="'+data.address+'" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input">'	
			  +'</div></div> '
			var cintroduction ='<div class="layui-form-item ">'
			    +'<label class="layui-form-label">自我介绍</label>'
			    +'<div class="layui-input-inline" style="width: 70%;">'
			     +' <textarea name="cintroduction"  disabled="disabled" class="layui-textarea">'+data.cintroduction+'</textarea>'
			   +' </div></div>'		
			var botton='<div class="layui-form-item">'
			    +'<div class="layui-input-block">'
			     /*+'<button class="layui-btn" id="send">编辑</button>'*/
			    +'<input type="button" class="layui-btn" onclick="set()" value="编辑">'
			    +'</div></div>'				
			var course='<div class="layui-form-item ">'
				+'<label class="layui-form-label">课程内容</label>'
				+'<div class="layui-input-inline" style="width: 70%;">'
				+' <textarea name="cintroduction" disabled="disabled"   class="layui-textarea">'+data.content+'</textarea>'
				+' </div></div>'			
			content+='<div class="layui-form-item">'+nickName
			+cname+'</div>'
			+sex		
			+'<div class="layui-form-item">'+cage+time+'</div>'
			+'<div class="layui-form-item">'+price+style+'</div>'+course+publicLevel
			+authentication+address+cintroduction+botton
			$("#updateMessage").html(content)			
		}	
	});
}

function set(){
	location.href="/html/coachCompile.html";
}
//头像显示
